<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('标杆项目列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <!-- 搜索 表单 -->
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            项目名：<input type="text" name="proName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <!-- 头工具栏 -->
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="monitor:job:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:post:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:post:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>

        <!-- 数据表格 即数据展示区 -->
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:post:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:post:remove')}]];
    var datas = [[${@dict.getType('sys_normal_disable')}]];
    var prefix = ctx + "pro";

    $(function () {
        var options = {
            url: prefix + "/soft/list",
            createUrl: prefix + "/file/add",
            updateUrl: prefix + "/file/edit/{id}",
            removeUrl: prefix + "/file/remove",
            sortName: "proId",
            modalName: "项目编号",
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'proId',
                    title: '项目编号'
                },
                {
                    field: 'proName',
                    title: '项目名称',
                    sortable: true
                },
                {
                    field: 'proBgTime',
                    title: '项目开始时间',
                    sortable: true
                },
                {
                    field: 'proOvTime',
                    title: '项目结束时间',
                    sortable: true
                },
                {
                    field: 'proDes',
                    title: '项目简介',
                    sortable: true
                },
                {
                    field: 'proAthor',
                    title: '负责人',
                    sortable: true
                },
                {
                    field: 'proAddress',
                    title: '项目施工地址',
                    sortable: true
                },
                {
                    visible: editFlag=='hidden' ? false : true,
                    title: '标杆文件',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
                },
                {
                    title: '图片',
                    formatter: function(value, row, index) {
                        return $.table.imageView('http://demo.ruoyi.vip'+row.imgUrl);
                    }
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.proId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.proId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });
    /* 标杆状态显示 */
    function statusTools(row) {
        if (row.proIsBench == 1) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.proId + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.proId + '\')"></i> ';
        }
    }
    /* 角色管理-停用 */
    function disable(proId) {
        $.modal.confirm("确认要取消标杆项目吗？", function() {
            $.operate.post(prefix + "/file/changeStatus", { "proId": proId, "proIsBench": 1 });
        })
    }

    /* 角色管理启用 */
    function enable(proId) {
        $.modal.confirm("确认要添加标杆项目吗？", function() {
            $.operate.post(prefix + "/file/changeStatus", { "proId": proId, "proIsBench": 0 });
        })
    }
</script>
</body>
</html>